home *** CD-ROM | disk | FTP | other *** search
-
- MSGCTL(2) UNIX Programmer's Manual MSGCTL(2)
-
- NNAAMMEE
- mmssggccttll - message control operations
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
- ##iinncclluuddee <<ssyyss//iippcc..hh>>
- ##iinncclluuddee <<ssyyss//mmssgg..hh>>
-
- _i_n_t
- mmssggccttll(_i_n_t _m_s_q_i_d, _i_n_t _c_m_d, _s_t_r_u_c_t _m_s_q_i_d___d_s _*_b_u_f)
-
- DDEESSCCRRIIPPTTIIOONN
- The mmssggccttll() system call performs some control operations on the message
- queue specified by _m_s_q_i_d.
-
- Each message queue has a data structure associated with it, parts of
- which may be altered by mmssggccttll() and parts of which determine the actions
- of mmssggccttll(). The data structure is defined in <_s_y_s_/_m_s_g_._h> and contains
- (amongst others) the following members:
-
- struct msqid_ds {
- struct ipc_perm msg_perm; /* msg queue permission bits */
- u_long msg_cbytes; /* # of bytes in use on the queue */
- u_long msg_qnum; /* # of msgs in the queue */
- u_long msg_qbytes; /* max # of bytes on the queue */
- pid_t msg_lspid; /* pid of last msgsnd() */
- pid_t msg_lrpid; /* pid of last msgrcv() */
- time_t msg_stime; /* time of last msgsnd() */
- time_t msg_rtime; /* time of last msgrcv() */
- time_t msg_ctime; /* time of last msgctl() */
- };
-
- The ipc_perm structure used inside the shmid_ds structure is defined in
- <_s_y_s_/_i_p_c_._h> and looks like this:
-
- struct ipc_perm {
- ushort cuid; /* creator user id */
- ushort cgid; /* creator group id */
- ushort uid; /* user id */
- ushort gid; /* group id */
- ushort mode; /* permission (9 bits, see chmod(2)) */
- ushort seq; /* sequence # (to generate unique id) */
- key_t key; /* user specified msg/sem/shm key */
- };
-
- The operation to be performed by mmssggccttll() is specified in _c_m_d and is one
- of:
-
- IPC_STAT Gather information about the message queue and place it in the
- structure pointed to by _b_u_f.
-
- IPC_SET Set the value of the _m_s_g___p_e_r_m_._u_i_d, _m_s_g___p_e_r_m_._g_i_d, _m_s_g___p_e_r_m_._m_o_d_e
- and _m_s_g___q_b_y_t_e_s fields in the structure associated with _m_s_q_i_d.
- The values are taken from the corresponding fields in the
- structure pointed to by _b_u_f. This operation can only be exe-
- cuted by the super-user, or a process that has an effective
- user id equal to either _m_s_g___p_e_r_m_._c_u_i_d or _m_s_g___p_e_r_m_._u_i_d in the
- data structure associated with the message queue. The value
- of _m_s_g___q_b_y_t_e_s can only be increased by the super-user. Values
- for _m_s_g___q_b_y_t_e_s that exceed the system limit (MSGMNB from
- <_s_y_s_/_m_s_g_._h>) are silently truncated to that limit.
-
-
-
- IPC_RMID Remove the message queue specified by _m_s_q_i_d and destroy the
- data associated with it. Only the super-user or a process with
- an effective uid equal to the _m_s_g___p_e_r_m_._c_u_i_d or _m_s_g___p_e_r_m_._u_i_d
- values in the data structure associated with the queue can do
- this.
-
- The permission to read from or write to a message queue (see msgsnd(2)
- and msgrcv(2)) is determined by the _m_s_g___p_e_r_m_._m_o_d_e field in the same way
- as is done with files (see chmod(2)), but the effective uid can match
- either the _m_s_g___p_e_r_m_._c_u_i_d field or the _m_s_g___p_e_r_m_._u_i_d field, and the effec-
- tive gid can match either _m_s_g___p_e_r_m_._c_g_i_d or _m_s_g___p_e_r_m_._g_i_d.
-
- RREETTUURRNN VVAALLUUEESS
- Upon successful completion, a value of 0 is returned. Otherwise, -1 is
- returned and the global variable _e_r_r_n_o is set to indicate the error.
-
- EERRRROORRSS
- mmssggccttll() will fail if:
-
- [EPERM] _c_m_d is equal to IPC_SET or IPC_RMID and the caller is not
- the super-user, nor does the effective uid match either the
- _m_s_g___p_e_r_m_._u_i_d or _m_s_g___p_e_r_m_._c_u_i_d fields of the data structure
- associated with the message queue.
-
- An attempt is made to increase the value of _m_s_g___q_b_y_t_e_s
- through IPC_SET but the caller is not the super-user.
-
- [EACCESS] The command is IPC_STAT and the caller has no read permis-
- sion for this message queue.
-
- [EINVAL] _m_s_q_i_d is not a valid message queue identifier.
-
- _c_m_d is not a valid command.
-
- [EFAULT] _b_u_f specifies an invalid address.
-
- SSEEEE AALLSSOO
- msgsnd(2), msgrcv(2), msgget(2)
-
- HHIISSTTOORRYY
- Message queues appeared in the first release of AT&T Unix System V.
-
- NetBSD August 17, 1995 2
-